library(tidyverse)
library(readxl)
path = "Excel/700-799/799/799 Remove Characters between 2 Asterisks.xlsx"
input = read_excel(path, range = "A1:A10")
test = read_excel(path, range = "B1:B10")
strip_star_pairs = function(x) {
while (str_detect(x, "\\*[^*]*\\*")) {
x = str_replace(x, "\\*([^*]*)\\*", ~str_remove_all(.x, "[A-Za-z]+"))
}
str_remove_all(x, "\\*")
}
result = input %>%
mutate(answer = map_chr(Data, strip_star_pairs))
all.equal(result$answer, test$`Answer Expected`)
# [1] TRUEExcel BI - Excel Challenge 799
excel-challenges
excel-formulas
🔰 Data Answer Expected constitution cotitution happiness haiess perception perception entertainment* entinme

Challenge Description
🔰 Data Answer Expected constitution cotitution happiness haiess perception perception entertainment* entinme
Solutions
- Logic: Read the workbook ranges needed for the challenge; Derive the required intermediate columns; Iterate through the sequence until the rule is satisfied.
- Strengths: The algorithm is explicit about the sequence rule, so the control flow is easy to validate against the prompt.
- Areas for Improvement: The solution assumes the workbook layout and selected ranges remain stable, so any structural change in the sheet would require small adjustments.
- Gem: The non-obvious part is the local rule inside the loop, because that rule determines the whole output.
import pandas as pd
import re
path = "700-799/799/799 Remove Characters between 2 Asterisks.xlsx"
input = pd.read_excel(path, usecols="A", nrows=10)
test = pd.read_excel(path, usecols="B", nrows=10)
def strip_star_pairs(x):
while True:
m = re.search(r"\*[^*]*\*", x)
if not m: break
inner = re.sub(r"[A-Za-z]+", "", x[m.start()+1:m.end()-1])
x = x[:m.start()] + inner + x[m.end():]
return x.replace("*", "")
input['answer'] = input.iloc[:, 0].apply(strip_star_pairs)
print(input['answer'].equals(test['Answer Expected'])) # TrueThe Python version expresses the core extraction rule directly and keeps the pattern matching easy to review.
Difficulty Level
Medium / Hard
The challenge relies on a non-obvious iterative rule rather than a single straight aggregation.